package com.demo.mapper;

import com.demo.pojo.Role;
import com.demo.pojo.User;
import com.demo.pojo.UserRole;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface UserMapper {
    @Select("select * from shiro_user")
    List<User> getAllUser();

    @Select("select * from shiro_user where name=#{name}")
    User getUserByName( @Param("name") String name);

    @Insert("insert into shiro_user (name, password,salt) values (#{name},#{password},#{salt})")
    int addUser(User user);

    @Update("update shiro_user set salt=#{salt} where id=#{id}")
    int updateUser(String salt,int id);

    @Delete("delete from shiro_user where id=#{id}")
    int deleteUser( @Param("id")int id);

    User getUserAndRole(@Param("name")String name);
}
